define([ "dojo/_base/declare", "widgets/baseWidget/BaseWidget",
    "dojo/text!./templates/Template.html","dojo/_base/fx","dojo/fx","dojo/fx/easing", "dojo/dom",
    "dojo/on","dojo/aspect","dojo/query","dijit/layout/ContentPane","dijit/layout/TabContainer","dojo/parser",
    "dojo/topic","dojo/_base/lang","dijit/layout/TabContainer","dojo/dom-construct"
    ],
    function(declare,BaseWidget, template,baseFx,fx,easing,Dom,on,aspect,query,ContentPane,TabContainer,Parser,
    			Topic,lang,TabContainer,domConstruct) {
	 
        return declare([ BaseWidget], {
        	//模板页面
            templateString : template,
            tabCom:null,
            hasExpand:true,//true:展开，flase:没展开
            panelWidth:260,
            relatedom:null,
            firstFlag :0,
            
            constructor : function() { 
            	// debugger;
            	this.inherited(arguments);
            },
            //组件初始化方法
            postCreate : function() {
            	domConstruct.place(this.domNode, dojo.body());
            	this.inherited(arguments);
            	this.tabCom=new TabContainer({region: 'center', tabPosition: 'top',useSlider:false});
            	this.tabCom.placeAt(this.tab2).startup();
            	this.setWidth();//设置宽度
            	on(this.expandBtn2,"click",dojo.hitch(this,this.detailExpand));
            	Topic.subscribe("detailExpand", lang.hitch(this, this.detailExpand));
 
            },
            startup:function(){
            	this.inherited(arguments);
            },
 
            
            setWidthSmall:function(){
            	var doms = query(".dijitTabInner");
            	var length = doms.length;
            	if (length < 4){
            		for(var i = 0; i < length; i++){
            			var dom = doms[i];
            			dojo.style(dom,"width","20px");
            		}
            	}
            },
            
            setWidth:function(){
            	//debugger;
            	var doms = query(".dijitTabInner");
            	var length = doms.length;
            	if (length > 4){
            		
            	}else{
            		var percent = parseFloat(1/length)*Global.layerPanelWidth;
            		for(var i = 0; i < length; i++){
            			var dom = doms[i];
            			dojo.style(dom,"width",percent+"px");
            		}
            	}
            },
            
 
            
            detailExpand:function(evt,force){
            	var c = this.data1;
            	if(evt.target.innerText!='返回'){
            		c.innerText = evt.target.innerText;
            	}
            	var anim=fx.combine([
					baseFx.animateProperty({
					    node: this.domNode,
					    properties: {
					        left: this.hasExpand?0:-this.panelWidth
					    }
					}) 
            	]);
            	anim.play();
            	this.hasExpand=this.hasExpand?false:true;
            		Topic.publish("expandLeft", lang.hitch(this, dojo.byId('expandLeft')));
            },
            
            destroy:function(){
            	this.inherited(arguments);
            }
        });
    });
